import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

import { DictEnum } from '@vben/constants';
// import { VbenIcon } from '@vben/icons';
// import { getPopupContainer } from '@vben/utils';

// import { Tag } from 'ant-design-vue';
// import { z } from '#/adapter/form';
// import { getDictOptions } from '#/utils/dict';
import { renderDict } from '#/utils/render';

export const columns: VxeGridProps['columns'] = [
  // {
  //   type: 'checkbox',
  //   width: 60,
  // },
  {
    dragSort: true,
    title: '拖拽排序',
    width: 100,
  },
  {
    type: 'seq',
    width: 60,
  },
  {
    field: 'questionName',
    title: '题目名称',
    align: 'left',
    minWidth: 200,
    slots: { default: 'questionName' },
  },
  {
    title: '题目类型',
    field: 'questionType',
    width: 150,
    slots: {
      default: ({ row }) => {
        return renderDict(
          row.questionType,
          DictEnum.QUESTIONNAIRE_QUESTION_TYPE,
          true,
        );
      },
    },
  },
  {
    title: '备注',
    field: 'remark',
    showOverflow: true,
    visible: false,
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    width: 160,
  },
];

export const questionSchema: FormSchemaGetter = () => [
  {
    label: 'ID',
    fieldName: 'id',
    component: 'Input',
    dependencies: {
      show: () => false,
      triggerFields: [''],
    },
  },
  {
    label: '问卷ID',
    fieldName: 'questionnaireId',
    component: 'Input',
    dependencies: {
      show: () => false,
      triggerFields: [''],
    },
  },
  {
    label: '选择题目',
    fieldName: 'questionId',
    component: 'QuestionSelect',
    rules: 'selectRequired',
  },
];
